package com.jpa.oneTomany;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * <p>Title:OrderItem</p>
 * <p>Description:</p>
 * @company sinobest 
 * @author Administrator
 * @date 2016年10月17日 下午10:34:35
 * 
 */
@Entity
@Table(name = "t_order_item")
public class OrderItem {
	
	private Integer orderItemId;
	private Float sellPrice =0f;
	private Order order;
	
	@Id
	@GeneratedValue
	@Column(name="id",length = 32)
	public Integer getOrderItemId() {
		return orderItemId;
	}
	public void setOrderItemId(Integer orderItemId) {
		this.orderItemId = orderItemId;
	}
	
	@Column(length=40,nullable=false)
	public Float getSellPrice() {
		return sellPrice;
	}
	public void setSellPrice(Float sellPrice) {
		this.sellPrice = sellPrice;
	}
	
	@ManyToOne(cascade={CascadeType.MERGE,CascadeType.REFRESH},//级联策略
			fetch=FetchType.EAGER//加载行为：默认为立即加载
			,optional=true  //可选，外键字段是否可以为空
			)
	public Order getOrder() {
		return order;
	}
	public void setOrder(Order order) {
		this.order = order;
	}
	
}
